<?php
/**
 * News Controller
 * 
 * @author CRIA Groep 1 <project@markvink.nl>
 * @version 1.0
 * @package controllers
 */
class NewsController extends AppController {
	/**
    * @var string Controller name (faster in PHP 4)
    */
	var $name = 'News';
	
	/**
    * @var string Scaffolding on prefix 
    */	
	var $scaffold = 'admin';
	
	/**
	 * Callback function beforeFilter
	 * 
	 * Get triggered after init.
	 */
	function beforeFilter() {
		parent::beforeFilter(); 
		$this->Auth->allowedActions = array('index', 'view');
		
		$newsitems = $this->News->find('all', array('order' => array('News.created'=>'desc')));
		$activeItem[0] = $newsitems[0];
		$this->set(compact('newsitems', 'activeItem'));
	}
	
	/**
	 * Function index
	 * 
	 * Controller action
	 */
	function index() {
		$this->render('view');
	}
	
	/**
	 * Function view
	 * 
	 * Controller action
	 * @param integer $id identifier
	 */
	function view($id = 0){
		$activeItem = array();
		if($id > 0){
			$activeItem = $this->News->find('all',array(
				'conditions' => array(
					'News.id' => $id
				)
			));
			$this->set(compact('activeItem'));
		}
	}
}
